package com.ruoyi.jiajia.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JiajiaZiZhi;
import com.ruoyi.system.service.IJiajiaZiZhiService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 社工资质证件Controller
 * 
 * @author knd
 * @date 2021-11-04
 */
@Controller
@RequestMapping("/jiajia/ziZhi")
public class JiajiaZiZhiController extends BaseController
{
    private String prefix = "jiajia/ziZhi";

    @Autowired
    private IJiajiaZiZhiService jiajiaZiZhiService;

    @RequiresPermissions("jiajia:ziZhi:view")
    @GetMapping()
    public String ziZhi()
    {
        return prefix + "/ziZhi";
    }

    /**
     * 查询家家到家资质证件列表
     */
    @RequiresPermissions("jiajia:ziZhi:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaZiZhi jiajiaZiZhi)
    {
        startPage();
        List<JiajiaZiZhi> list = jiajiaZiZhiService.selectJiajiaZiZhiList(jiajiaZiZhi);
        return getDataTable(list);
    }

    /**
     * 导出家家到家资质证件列表
     */
    @RequiresPermissions("jiajia:ziZhi:export")
    @Log(title = "家家到家资质证件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaZiZhi jiajiaZiZhi)
    {
        List<JiajiaZiZhi> list = jiajiaZiZhiService.selectJiajiaZiZhiList(jiajiaZiZhi);
        ExcelUtil<JiajiaZiZhi> util = new ExcelUtil<JiajiaZiZhi>(JiajiaZiZhi.class);
        return util.exportExcel(list, "家家到家资质证件数据");
    }

    /**
     * 新增家家到家资质证件
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存家家到家资质证件
     */
    @RequiresPermissions("jiajia:ziZhi:add")
    @Log(title = "家家到家资质证件", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaZiZhi jiajiaZiZhi)
    {
        return toAjax(jiajiaZiZhiService.insertJiajiaZiZhi(jiajiaZiZhi));
    }

    /**
     * 修改家家到家资质证件
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaZiZhi jiajiaZiZhi = jiajiaZiZhiService.selectJiajiaZiZhiById(id);
        mmap.put("jiajiaZiZhi", jiajiaZiZhi);
        return prefix + "/edit";
    }

    /**
     * 修改保存家家到家资质证件
     */
    @RequiresPermissions("jiajia:ziZhi:edit")
    @Log(title = "家家到家资质证件", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaZiZhi jiajiaZiZhi)
    {
        return toAjax(jiajiaZiZhiService.updateJiajiaZiZhi(jiajiaZiZhi));
    }

    /**
     * 删除家家到家资质证件
     */
    @RequiresPermissions("jiajia:ziZhi:remove")
    @Log(title = "家家到家资质证件", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaZiZhiService.deleteJiajiaZiZhiByIds(ids));
    }
}
